//
//  LRDismissAnimation.swift
//  LRWeibo
//
//  Created by 雷路荣 on 15/12/31.
//  Copyright © 2015年 leilurong. All rights reserved.
//

import UIKit

///控制关闭时的动画
class LRDismissAnimation: NSObject, UIViewControllerAnimatedTransitioning {
    
    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.25
    }
    
    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        
        let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)
        
        UIView.animateWithDuration(transitionDuration(transitionContext), animations: { () -> Void in
            //注意缩放的y值不能写0，否则没有动画效果
            fromView?.transform = CGAffineTransformMakeScale(1, 0.0001)//不能写0
            }) { (_) -> Void in
            //通知完成
            transitionContext.completeTransition(true)
        }
    }
}

















































